import time,random,os
from cache import my_cache
from config import REDIS_MSG_CODE_KEY
from ronglian_sms_sdk import SmsSDK

accId = '2c94811c853e09e0018543237cc80038'
accToken = '1bb7b99dd0104bd78d9b286338ac57b1'
appId = '2c94811c853e09e0018543237d8b003f'

def send_one_code(mobile):
     #生成短信验证码
     data = random.randint(100000, 999999)
     time.sleep(3)
     my_cache.setex(REDIS_MSG_CODE_KEY + mobile, time=120, value=data)
     sdk = SmsSDK(accId, accToken, appId)
     tid = '1'
     datas = (data, '5')
     resp = sdk.sendMessage(tid, mobile, datas)
     return resp

